package com.atguigu.gulimall.ware.config;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class MyRabbitTemplateConfig {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void initRabbitmqTemplate(){
        rabbitTemplate.setConfirmCallback((correlationData,ack,cause) -> {
            System.out.println("confirm..."+correlationData+"===ack:"+ack+"===cause:"+cause);
        });

        rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> {
            System.out.println("message:"+message+"==replyCode"+replyCode+"==replyText"+replyText+"==exchange:"+exchange+"===routingkey"+routingKey);
        });
    }
}
